/*
 * Parser.cpp
 *
 *  Created on: 15.04.2012
 *      Author: Eugene Kornykhin
 */

#include "Parser.h"
#include "parser/SimpleLexer.hpp"
#include "parser/SimpleParser.hpp"

Parser::Parser() {

}

Parser::~Parser() {
}

void Parser::parse(istream& input) {
	SimpleLexer lexer(input);
	SimpleParser parser(lexer);
	parser.program();
	poliz = parser.getPoliz();
	vars = parser.getVars();

	if (! poliz.hasProcedure("main")) {
		throw logic_error("Procedure main isn't found");
	}
}

map<string, int> Parser::getVars() const
{
	return vars;
}



const Poliz & Parser::getPoliz() const
{
	return poliz;
}




